package com.chaofan.controller;

import com.chaofan.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/user")
public class UserCOntroller {

    @PostMapping("/t1")
    public String test1(@RequestParam("username") String name, Model model) {
        System.out.println(name);
        model.addAttribute("msg", name);

        return "hello";
    }

    @RequestMapping("/t2")
    public String test2(User user, Model model) {

        model.addAttribute("msg",user);
        return "hello";
    }
}
